import request from "@/utils/request"

// 字典类型列表
export function queryDictionary(data, { currentPage, size }) {
  return request({
    url: `/sysDictType/search/${currentPage}/${size}`,
    method: "post",
    data
  })
}

// 新增字典类型
export function addDictionary(data) {
  return request({
    url: `/sysDictType`,
    method: "post",
    data
  })
}

// 修改字典类型
export function updateDictionaryApi(data) {
  return request({
    url: `/sysDictType`,
    method: "put",
    data
  })
}

// 字典类型详情
export function queryDictionaryDetail(id) {
  return request({
    url: `/sysDictType/${id}`,
    method: "get",
  })
}

// 删除字典类型
export function deleteDictionary(id) {
  return request({
    url: `/sysDictType/${id}`,
    method: "delete",
  })
}

// 字典值列表
export function queryDictionaryData(data, { currentPage, size }) {
  return request({
    url: `/sysDictData/search/${currentPage}/${size}`,
    method: "post",
    data
  })
}

// 新增字典值
export function addDictionaryData(data) {
  return request({
    url: `/sysDictData`,
    method: "post",
    data
  })
}

// 修改字典值
export function updateDictionaryData(data) {
  return request({
    url: `/sysDictData`,
    method: "put",
    data
  })
}

// 字典类型详情
export function queryDictionaryDataDetail(id) {
  return request({
    url: `/sysDictData/${id}`,
    method: "get",
  })
}

// 删除字典类型
export function deleteDictionaryData(id) {
  return request({
    url: `/sysDictData/${id}`,
    method: "delete",
  })
}



export function queryDictionaryValue(params) {
  return request({
    url: "/queryDictionaryValue",
    method: "get",
    params
  })
}

/** 增 */
export function createTableDataApi(data) {
  return request({
    url: "table",
    method: "post",
    data
  })
}

/** 删 */
export function deleteTableDataApi(id) {
  return request({
    url: `table/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateTableDataApi(data) {
  return request({
    url: "table",
    method: "put",
    data
  })
}


// 根据传入类型获取相应字典
export function getDictType(type) {
  return request({
    url: `/sysDictData/getDictDateByType/${type}`,
    method: "get",
  })
}
